package org.hxyjs.utils.messageFactory;



import org.hxyjs.entity.User;
import org.hxyjs.utils.MailHtmlUtils;
import org.hxyjs.vo.MailUser;

public class UserMessageFactory implements MakeMessage{
    public String[] getMessage(MailUser mailUser, String opDeatil){
        User user = (User)mailUser;
        System.out.println(123456);
        System.out.println(user.getMailAddress());
        String subject = null;
        StringBuilder mailMessage = new StringBuilder();
        String[] split = opDeatil.split(";");
        switch (split[0]){
            case "addUser":
                mailMessage.append("亲爱的用户"+user.getUname()+":<br>");
                mailMessage.append("注册成功");
                mailMessage.append("<a href=\"http://localhost:9091/userController/activate/"+user.getUno()+"\">激活</a>");
                subject = "亲爱的用户"+user.getUname()+"注册成功";//邮件标题

                break;
            case "addOrder":
                mailMessage.append("亲爱的用户"+user.getUname()+":<br>");
                mailMessage.append("下单成功,购买用户");

                mailMessage.append("");
                subject = "亲爱的用户"+user.getUname() + "您的的方案有新的会员购买";
                break;

            case "lettory":
                mailMessage.append("亲爱的用户"+user.getUname()+":<br>");
                String giftNames[]={"微波炉一台","电视一台","风扇一个","平底锅一个","代金券1000元","洗衣机一台","冰箱一台"};
                int index = Integer.parseInt(split[1]);
                        mailMessage.append("<img src='http://localhost:8080/static/images/gift/"+index+".jpg' style='width=200px;height=200px'/>");


                mailMessage.append("中奖了！！！恭喜您中得"+giftNames[index]);
                subject = "亲爱的用户"+user.getUname()+"您中奖了！";//邮件标题

                break;

            case "timeout": break;
            default:break;
        }
        String [] mail = new String[2];
        mail[0] = subject;
        mail[1] = MailHtmlUtils.initHtml(mailMessage.toString());
        System.out.println();
        System.out.println(mail[1]);
        return mail;
    }
}
